package sdk.pay.utils;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;

import sdk.pay.constant.PayConfigure;
import sdk.pay.constant.PayConstant;


/**
 * Created by Administrator on 2017/8/5.
 */

public class PayURLSPUtil {

    public SharedPreferences mSharedPreferences;

    public PayURLSPUtil(Activity activity) {
        mSharedPreferences = activity.getSharedPreferences(PayConstant.SHAREPERFERENCE_NAME, Context.MODE_PRIVATE);
    }

    public void clearPayUrl() {
        PayConfigure.PAY_URL = null;
        SharedPreferences.Editor editor = mSharedPreferences.edit();
        editor.putInt(PayConstant.SHAREPERFERENCE_SERVCERS_SUM_KEY, 0);
        editor.putInt(PayConstant.SHAREPERFERENCE_SERVCERS_CURRENT_KEY, 0);
        editor.putString(PayConstant.SHAREPERFERENCE_MSG_KEY, null);
        editor.apply();
    }

    public void clearOrderServerUrl() {
        PayConfigure.PAY_URL_PAY = null;
        SharedPreferences.Editor editor = mSharedPreferences.edit();
        editor.putInt(PayConstant.SHAREPERFERENCE_ORDERSERVERS_SUM_KEY, 0);
        editor.putInt(PayConstant.SHAREPERFERENCE_ORDERSERVERS_CURRENT_KEY, 0);
        editor.putString(PayConstant.SHAREPERFERENCE_MSG_KEY, null);
        editor.apply();
    }

    public void clearAllServerUrl() {
        PayConfigure.PAY_URL = null;
        PayConfigure.PAY_URL_PAY = null;
        SharedPreferences.Editor editor = mSharedPreferences.edit();
        editor.putInt(PayConstant.SHAREPERFERENCE_SERVCERS_SUM_KEY, 0);
        editor.putInt(PayConstant.SHAREPERFERENCE_SERVCERS_CURRENT_KEY, 0);
        editor.putInt(PayConstant.SHAREPERFERENCE_ORDERSERVERS_SUM_KEY, 0);
        editor.putInt(PayConstant.SHAREPERFERENCE_ORDERSERVERS_CURRENT_KEY, 0);
        editor.putString(PayConstant.SHAREPERFERENCE_MSG_KEY, null);
        editor.apply();
    }

}
